#{extends 'overlay.html' /}


   
  <script type="text/javascript"> 
$(function() {

	$('#object_startTimeShown').datepicker({  
		changeMonth: true,
		changeYear: true,
	    showTime: true,
	    minDate: new Date(),
		dateFormat: '@'
	 
	 });
	$('#object_endTimeShown').datepicker({  
		changeMonth: true,
		changeYear: true,
	    showTime: true,
	    minDate: new Date(),
		dateFormat: '@'
		
	 });
});

function showStuff(id) {
	if(document.getElementById(id).style.display == 'block')
		{
		document.getElementById(id).style.display = 'none';
		document.getElementById('types').style.display='none';
		var o=document.getElementById('object_sprint');
		o.value='none';
		var z=document.getElementById('object_type');
		z.value='none';
				}
	else{
		document.getElementById(id).style.display = 'block';
		document.getElementById('types').style.display='block';
	}
	}


function setTime(start)
{
	if(start)
	setTimeout("set_startTime()", 50);
	else
	setTimeout("set_endTime()", 50);
}
function set_startTime()
{

		var time= $('#object_startTimeShown').val();
		$('#object_startTime').val(time);
		var tobeShown= get_theDate(time);
		document.getElementById('object_startTimeShown').value= tobeShown;
	
}

function set_endTime()
{

	var time= $('#object_endTimeShown').val();
	$('#object_endTime').val(time);
	var tobeShown= get_theDate(time);
	document.getElementById('object_endTimeShown').value= tobeShown;
	
}

function get_theDate(date)
{
	var theDate= new Date(parseInt(date));
	var y= theDate.getFullYear();
	var m= theDate.getMonth()+1;
	var d= theDate.getDate();
	var h= theDate.getHours();
	var min= theDate.getMinutes();
	if(m<10)
	{
		m='0'+m;
	}
	if(d<10)
	{
		d='0'+d;
	}
	if(h<10)
	{
		h='0'+h;
	}
	if(min<10)
	{
		min='0'+min;
	}
	return ""+d+"/"+m+"/"+y+" "+h+" : "+min;
}

$(function() 
		{
	var x=get_theDate(${object.startTime})
	var y=get_theDate(${object.endTime})
	$('#object_endTimeShown').val(y);
	$('#object_startTimeShown').val(x);
		})

	</script>
   

<div id="crudBlank" class="${type.name}">
	
	<h2 id="crudBlankTitle">&{'crud.blank.title', type.modelName}</h2>
	
	<div class="objectForm">
	#{form action:@save(object.id), enctype:'multipart/form-data'}
		<div class="crudField">
			<label for="object_name"> Name</label> <br>
			<input id="object_name" class="" type="text" name="object.name" value="${object.name}" size="50" /> 
			<span class="crudHelp" style="color:red">*</span>
		</div>
		
		<div class="crudField more_options">
			<label for="object_description"> Description </label> <br></br>
			<TextArea id="object_description" class="" type="text" name="object.description" rows ="5" value="${object.description}" cols="52" /> </TextArea>	
    	</div>
		<div class="crudField">
			<label for="object_location"> Location</label> <br> </br>
			<input id="object_location" class="" type="text" name="object.location" value="${object.location}" size="50" /> 
		    <span class="crudHelp" style="color:red"> *</span>
		</div>
		<div class="crudField">
			<label for="object_startTime"> Start time  </label><br> 
				<input id="object_startTimeShown" class="" type="text" name="object.startTimeShown" onChange="setTime(true)" value="" size="50" readonly /> 
			    <input id="object_startTime" class="" type="text" name="object.startTime" value="${object.startTime}" size="50" style="display:none"/> 
			    <span class="crudHelp" style="color:red">*</span><br />Unless you specify otherwise, this meeting will last one hour.
		</div>
		
		<div class="crudField more_options">
			<label for="object_endTime"> End Time </label> <br>
			<input id="object_endTimeShown" class="" type="text" name="object.endTimeShown" onChange="setTime(false)" value="" size="50" readonly/> 
			<input id="object_endTime" class="" type="text" name="object.endTime" value="${object.endTime}" size="50" style="display:none"/>
		</div>
		#{if sprints.size()!=0 }
		<div class="crudField more_options">	
				<label for="object_sprint">Associate to Sprint</label>
				<input type="checkbox" name="associateSprintBox" onclick="showStuff('span');">
				<span id="span" style="display: none;">
				<select id="object_sprint" name="object.sprintid"  >
				
				#{list items:sprints, as:'sprint'}
					<option   value="${sprint.id}">Sprint ${sprint.sprintNumber}</option>
						#{/list}
						</select>
						</span>
	    	<span class="crudHelp"></span>
			
		</div>
		<div class="crudField hidden" id="types">
					<label for="object_type">Type of Meeting</label>
							<select id="object_type" name="object.type">
							#{list items:types, as:'meetingtype'}
							<option  value="${meetingtype}">${meetingtype}</option>
							#{/list}
							</select>
		</div>
		#{/if}
		
					<a href="#" onclick="$('.more_options').toggle()">Toggle more options</a>
			
		 <br> <br> </br> 
		
		 
		
		 <p style="color:red" size=""> <small> * Required Fields. </small> </p> 
		
		<br> <br>
		
		<p class="crudButtons">
			<input type="submit" name="_save" value="&{'crud.save', type.modelName}" />

		</p>
	#{/form}
	</div>

</div>
 
		     
		     
		     
			     
		     
		     
		     
     